<template>
	<view>
		<uni-list>
			<uni-swipe-action ref="swipeAction">
				<uni-swipe-action-item v-for="(item, index) in tableData" :right-options="options1" :key="item.id" @click="swipeClick($event, item)">
					<uni-list-item :title="item.name" :note="item.createTime" showArrow clickable :rightText="item.planRoute" @click="ToDetail(item)" />
				</uni-swipe-action-item>
			</uni-swipe-action>
		</uni-list>
	</view>
</template>

<script>
import { getInspectionList, delInspectionList } from '@/api/system/user.js';
export default {
	data() {
		return {
			tableData: [],
			options1: [
				{
					text: '删除',
					style: {
						backgroundColor: '#F56C6C'
					}
				}
			]
		};
	},
	onLoad() {
		this.GetInspectionList();
	},
	methods: {
		async GetInspectionList() {
			await getInspectionList().then((res) => {
				this.tableData = res.rows;
				console.log('getInspectionList', res.rows);
			});
		},
		ToDetail(b) {
			uni.navigateTo({
				url: `/pages/work/InspectionPlan/detail?data=${JSON.stringify(b)}`
			});
			// this.$tab.navigateTo('/pages/work/CustomsDeclaration/detail');
			// store.state.CusImform = b;
			// console.log('store.state.CusImform:', store.state.CusImform);
		},
		//左滑触发
		swipeClick(e, item) {
			let { content } = e;
			if (content.text === '删除') {
				delInspectionList(item.planId).then((res) => {
					this.GetInspectionList();
					console.log('planId', item.planId);
				});
				// this.popValue = item.content;
				// uni.navigateTo({
				// 	url: `/pages/work/SubOrder?id=${item.id}`
				// });
				// this.$tab.navigateTo('/pages/work/SubOrder');
				// console.log('item', item);
			}
		}
	}
};
</script>

<style lang="scss"></style>
